package com.kuizii.demo.core.config;

import io.lettuce.core.ReadFrom;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LettuceConfig {

    /**
     * 演示用  ，当redis为主从时，优先在从库读取则会导致分布式锁因同步延迟而锁失败
     *
     * @return
     */
    @Bean
    public LettuceClientConfigurationBuilderCustomizer readFrom() {
        return x -> x.readFrom(ReadFrom.MASTER);
    }
}
